package day06;

import java.util.Scanner;

public class Day06Text2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入有几位评委：");
        double sum = sum(scan.nextInt());
        System.out.println("总分是："+sum);
    }
    //填入评委分数
    public static double[] inputData(int n){
        Scanner scan = new Scanner(System.in);
        double[] scores=new double[n];
        for (int i=0;i<scores.length;i++){
            System.out.println("请输入第"+(i+1)+"位评委的分数");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }
    //求平均分和总分
    public static double sum(int n){
        double[] scores =inputData(n);
        double sum = 0;
        double avg = 0;
        double max = scores[0];
        double min = scores[0];
        for (int i =0;i<scores.length;i++){
            if (scores[i]>max){
                max = scores[i];
            }
            if (scores[i]<min){
                min = scores[i];
            }
            sum = sum + scores[i];
        }
        System.out.println("最大值是："+max);
        System.out.println("最小值是："+min);
        sum = sum -max-min;
        avg = sum /(n-2);
        System.out.println("平均值是："+avg);
        return sum;
    }
}
